﻿@model Telecom.Data.LAP_THIETBI

@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestAdUpLTB"
    };
}

<script type="text/javascript">

    function opBeginProcess_loading_window_submit() {

        var gDMTHIETBIAdUpLTB = $('#DMTHIETBIAdUpLTB').combogrid('grid');	// get datagrid object
        var rDMTHIETBIAdUpLTB = gDMTHIETBIAdUpLTB.datagrid('getSelected');
        $("#DMTHIETBI_AdUpTb").val(rDMTHIETBIAdUpLTB.ID);

        var valueDate = $('#date_ngay_lap_Dat_thiet_bi').datebox('getValue');
        if (valueDate == null || valueDate == "") {
            $("#NGAY_LAPDAT_AdUpTb").val("");
        }

        $("#ContentwindowFunction").mask("Dữ liệu đang xử lý");
    }

    function completedAjaxRequestAdUpLTB(obj) {

        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {


            $('#lap_thiet_bi_tbvt_TableContainer').jtable('reload');

            close_window_elements('window_addupdate_lapthietbiCard_thietbi');


        } else {

            $("#ContentwindowFunction").unmask();
            confirmOptionNormal(returnObj.Message);
        }

        return false;

    }

    $(document).ready(function () {

        

        $("#date_ngay_lap_Dat_thiet_bi").datebox({
            formatter: formatterDateDDMMYY,
            parser: parserDateDDMMYY,
            onSelect: function (date) {
                $("#NGAY_LAPDAT_AdUpTb").val(date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear());
            }
        });

        $("#DONVIQLAdUpLTB").combobox({

            url: _nameSubDomain + "/Donvi_ToQL/Get_DonVi_To_OnJson_InsertText",
            valueField: "id",
            textField: "text",
            onSelect: function (row) {

                $("#DONVIQL_AdUpTb").val(row.id);
                $("#TOQLAdUpLTB").combobox({ url: _nameSubDomain + "/Donvi_ToQL/Get_ToAL_To_OnJson_InsertText?ma=" + row.id });
                $("#SITEIDAdUpLTB").combogrid({ url: _nameSubDomain + "/Vnpt_Site/listVNPTSITEONDONTOQL_MAVT?mavt=@ViewBag.MangVTADDLTB&toql=&donvi=" + row.id });
                $("#TOQL_AdUpTb").val("");
                $("#SITEID_AdUpLTB").val(0);

            }

        });

        $("#TOQLAdUpLTB").combobox({

            url: _nameSubDomain + "/Donvi_ToQL/Get_ToAL_To_OnJson_InsertText?ma=@Model.DONVIQL",
            valueField: "MA",
            textField: "TEN",
            onSelect: function (row) {

                $("#SITEIDAdUpLTB").combogrid({ url: _nameSubDomain + "/Vnpt_Site/listVNPTSITEONDONTOQL_MAVT?mavt=@ViewBag.MangVTADDLTB&toql=" + row.MA + "&donvi=" + $("#DONVIQL_AdUpTb").val() });
                $("#TOQL_AdUpTb").val(row.MA);

            },

        });

        @*$("#SITEIDAdUpLTB").combobox({
            url: _nameSubDomain + "/Vnpt_Site/listVNPTSITEONDONTOQL_MAVT?mavt=@ViewBag.MangVTADDLTB&toql=@Model.TOQL&donvi=@Model.DONVIQL",
            valueField: "SITEID",
            textField: "TEN",
            onSelect: function (row) {

                $("#SITEID_AdUpLTB").val(row.SITEID);

            }

        });*@


        $("#SITEIDAdUpLTB").combogrid({

            url: _nameSubDomain + "/Vnpt_Site/listVNPTSITEONDONTOQL_MAVT?mavt=@ViewBag.MangVTADDLTB&toql=" + $("#TOQL_AdUpTb").val() + "&donvi=" + $("#DONVIQL_AdUpTb").val(),
            idField: 'SITEID',
            textField: 'TEN',
            fitcomlumm: true,
            columns: [[
                { field: 'MA', title: 'Mã Site', width: 150 },
                { field: 'DIACHI', title: 'Địa chỉ', width: 260 },
            ]],
            onSelect: function (index, row) {

                $("#SITEID_AdUpLTB").val(row.SITEID);

            }

        });


        $("#DMTHIETBIAdUpLTB").combogrid({

            url: _nameSubDomain + "/Dm_ThietBi/ListThietBiInJsonByMVT?maVt=@ViewBag.MangVTADDLTB",
            panelWidth:450,
            idField: 'ID',
            textField: 'TEN',
            fitcomlumm: true,
            columns:[[
                { field: 'MA', title: 'Mã TB', width: 90 },
                { field: 'TEN', title: 'Tên TB', width: 200 },
                {
                    field: 'LOAITB', title: 'Loại TB', width: 150, formatter: function (value, row) {
                        return get_loai_thietbi_byId(value).TEN;
                    },
                },
            ]],
            onSelect: function (index, row) {

                $("#DMTHIETBI_AdUpTb").val(row.ID);
                $("#MaTBChosse_lapTb").val(row.MA);

            }
        });

        $("#LOAIPHAAdUpLTB").combogrid({

            url: _nameSubDomain + "/TThietbi/ListLoaiPha?mvt=@ViewBag.MangVTADDLTB",
            idField: 'MA',
            textField: 'TEN',
            fitcomlumm: true,
            columns: [[
                //{ field: 'MA', title: 'Mã Pha', width: 90 },
                { field: 'TEN', title: 'Tên Pha', width: 440 },
                //{ field: 'LOAI', title: 'Loại Pha', width: 160 },
                
            ]],
            onSelect: function (index,row) {

                $("#LOAIPHA_AdUpTb").val(row.MA);

            }

        });


    });

    function loadwindow_add_site_laptb() {

        loadwindowOnContent(_nameSubDomain + "/Vnpt_Site/AddVNPTSITE_LAPTB?ma=" + $("#MA_LAP_TB").val() + "&ten=" + $("#TEN_LAP_TB").val() + "&loaiSite=@ViewBag.MangVTADDLTB" + "&donvi=" + $("#DONVIQL_AdUpTb").val() + "&toql=" + $("#TOQL_AdUpTb").val(), "window_add_vnpt_site_laptb", "Thêm VNPT SITE", 620, 600);

    }

</script>

@using (Ajax.BeginForm("_openWinDowLapDatTB", "ThietbiVT", null, ajaxOpts, new { enctype = "multipart/form-data" }))
{
    @Html.HiddenFor(model => model.ID)
    @Html.HiddenFor(model => model.SITEID, new { id = "SITEID_AdUpLTB" })
    @Html.HiddenFor(model => model.TOQL, new { id = "TOQL_AdUpTb" })
    @Html.HiddenFor(model => model.DONVIQL, new { id = "DONVIQL_AdUpTb" })
    @Html.HiddenFor(model => model.DMTHIETBI, new { id = "DMTHIETBI_AdUpTb" })
    @Html.HiddenFor(model => model.DAULUONG, new { id = "DAULUONG_AdUpTb" })
    @Html.HiddenFor(model => model.LOAIPHA, new { id = "LOAIPHA_AdUpTb" })
    @Html.HiddenFor(model => model.NGAYLAP, new { id = "NGAY_LAPDAT_AdUpTb" })

    <input type="hidden" id="typeTRamVTADDLAPTB" name="typeTRamVTADDLAPTB" value="@ViewBag.MangVTADDLTB" />
    <input type="hidden" id="MaTBChosse_lapTb" name="MaTBChosse_lapTb" value="" />
    
    <div id="ContentwindowFunction" class="ContentwindowFunction">
        <table class="tableContentWindowFunction">
            <tr>
                <td>Đơn vị QL
                </td>
                <td>
                    <input class="easyui-combobox" value="@Model.DONVIQL" style="width:450px; height:27px" id="DONVIQLAdUpLTB" name="DONVIQLAdUpLTB">
                </td>
            </tr>
            <tr>
                <td>Tổ QL
                </td>
                <td>
                    <input class="easyui-combobox" value="@Model.TOQL" style="width:450px;height:27px" id="TOQLAdUpLTB" name="TOQLAdUpLTB">
                </td>
            </tr>
            
            <tr>
                <td>Thiết bị
                </td>
                <td style="position:relative">
                    <input class="easyui-combogrid" value="@Model.DMTHIETBI" style="width:450px; height:27px" id="DMTHIETBIAdUpLTB" name="DMTHIETBIAdUpLTB">
                </td>
            </tr>
            <tr>
                <td>Mã TB
                </td>
                <td>
                    @Html.TextBoxFor(model => model.MA, new { id="MA_LAP_TB", @class = "input_table_function maTable" })
                </td>
            </tr>
            <tr>
                <td>Tên TB
                </td>
                <td>
                    @Html.TextBoxFor(model => model.TEN, new { id="TEN_LAP_TB", @class = "input_table_function" })
                </td>
            </tr>
            <tr>
                <td>Site bản đồ
                </td>
                <td style="position:relative;">
                    <input class="easyui-combogrid" value="@Model.SITEID" style="width:415px;height:27px" id="SITEIDAdUpLTB" name="SITEIDAdUpLTB">
                    <div style="position: absolute;top: 5px;right: 20px;">
                         <button type="button" onclick="return loadwindow_add_site_laptb();" style="padding:3px 0" >
                            <span class="l-btn-left l-btn-icon-left"><span class="l-btn-text"></span><span class="l-btn-icon icon-add">&nbsp;</span></span>
                         </button>
                    </div>
                </td>
            </tr>
            <tr>
                <td>Loại pha
                </td>
                <td>
                    <input class="easyui-combogrid" value="@Model.LOAIPHA" style="width:450px; height:27px" id="LOAIPHAAdUpLTB" name="LOAIPHAAdUpLTB">
                </td>
            </tr>
            <tr>
                <td>Ngày lắp đặt
                </td>
                <td>
                    <input id="date_ngay_lap_Dat_thiet_bi" value="@ViewBag.DateNowLAPTB" style="width:450px;height:27px" />
                </td>
            </tr>
            <tr>
                <td>Ghi chú
                </td>
                <td>
                    @Html.TextAreaFor(model => model.GHICHU, new { @class = "input_table_function" })
                </td>
            </tr>
        </table>
        <div style="height: 20px"></div>
        <div class="footer_submit" style="margin-top: 0px; text-align: center">
            <button type="submit" onclick="return opBeginProcess_loading_window_submit(); ">
                <span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">Cập nhật thiết bị</span><span class="l-btn-icon icon-add">&nbsp;</span></span>
            </button>
            <button type="button" onclick="return close_window_elements('window_addupdate_lapthietbiCard_thietbi');">
                <span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">Hủy bỏ</span><span class="l-btn-icon icon-remove">&nbsp;</span></span></button>
        </div>
    </div>
    

}